package net.qhzw.vip.qiyu.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.qhzw.vip.qiyu.dto.MyOrderDto;
import net.qhzw.vip.qiyu.entity.Order;
import net.qhzw.vip.qiyu.mapper.OrderMapper;
import net.qhzw.vip.qiyu.service.MyOrderService;
import net.qhzw.vip.qiyu.util.PageAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lgh on 2018/09/15.
 */
@Service
public class MyOrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements MyOrderService {

    @Autowired
    private OrderMapper orderMapper;

    private static final Logger log = LoggerFactory.getLogger(MyOrderServiceImpl.class);


    @Override
    public IPage<MyOrderDto> pageMyOrderByUserIdAndStatus(Page<MyOrderDto> page, Long userId, Integer status) {
        List<MyOrderDto> myOrderDtos = orderMapper.listMyOrderByUserIdAndStatus(new PageAdapter(page), userId, status);
        Long total = orderMapper.countMyOrderByUserIdAndStatus(userId, status);
        page.setRecords(myOrderDtos);
        page.setTotal(total);
        return page;
    }

}
